<?php
return [
    // 模块信息
    'module' => [
        'name' => 'user',  // 模块名称
        'title' => '用户管理',  // 模块标题
        'table' => 'users',  // 数据表名
    ],
    
    // 字段定义
    'fields' => [
        'id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '用户ID',
            'primary' => true,
            'auto_increment' => true,
            'nullable' => false,
            'required' => true,
        ],
        'username' => [
            'type' => 'varchar',
            'length' => 50,
            'comment' => '用户名',
            'required' => true,
            'rules' => 'required|unique:users',
            'nullable' => false,
        ],
        'password' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '密码',
            'required' => true,
            'hidden' => true,
            'nullable' => false,
        ],
        'email' => [
            'type' => 'varchar',
            'length' => 100,
            'comment' => '邮箱',
            'required' => true,
            'rules' => 'required|email|unique:users',
            'nullable' => false,
        ],
        'status' => [
            'type' => 'tinyint',
            'length' => 1,
            'comment' => '状态',
            'default' => 1,
            'options' => [
                0 => '禁用',
                1 => '启用'
            ],
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true
        ],
        'updated_at' => [
            'type' => 'timestamp',
            'comment' => '更新时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
            'extra' => 'ON UPDATE CURRENT_TIMESTAMP'
        ],
    ],
    
    // 关联关系
    'relations' => [
        'posts' => [
            'type' => 'hasMany',
            'model' => 'Post',
            'foreign_key' => 'user_id',
        ],
    ],
    
    // 查询条件
    'queries' => [
        'username' => ['like', '%?%'],
        'email' => ['like', '%?%'],
        'status' => ['=', '?'],
    ],
]; 